﻿package ${Package}.Entity;
import org.hibernate.annotations.GenericGenerator;
import org.apache.struts2.json.annotations.JSON;
import javax.persistence.*;
import java.sql.Timestamp;
/*
*author:徐洪昌
*blog:http://cnblogs.com/xusir
*datetime:${Utils.GetDate} ${Utils.GetTime}
*/ 
@Table(name = "$table.TableName", schema = "", catalog = "zichengdb")
@Entity
public class $table.TableNameAlias  implements java.io.Serializable{
#foreach($column in $ColumnList)
#set($columnName=${Utils.ToTitleLower(${column.ColumnNameAlias})})
private $column.ColumnType $columnName;
#if($column.IsPrimary)
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "$column.ColumnName", unique = true, nullable = false)
#else
	@Column(name = "$column.ColumnName")
	@Basic
	#if($column.ColumnType=="Timestamp")
		@JSON(format = "yyyy-MM-dd HH:mm")
	#elseif($column.ColumnType=="Date")
	    @JSON(format = "yyyy-MM-dd")
	#end
#end
    public $column.ColumnType get${column.ColumnNameAlias}() {
        return $columnName;
    }
    public void set${column.ColumnNameAlias}($column.ColumnType $columnName) {
        this.$columnName = $columnName;
    }
#end

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ${table.TableNameAlias} that = (${table.TableNameAlias}) o;
#foreach($column in $ColumnList)
#set($columnName=${Utils.ToTitleLower(${column.ColumnNameAlias})})
        if (${columnName} != null ? !${columnName}.equals(that.${columnName}) : that.${columnName} != null) return false;
#end
        return true;
    }

    @Override
    public int hashCode() {
        int result =0;
		#foreach($column in $ColumnList)
		#set($columnName=${Utils.ToTitleLower(${column.ColumnNameAlias})})
		result = 31 * result + (${columnName} != null ? ${columnName}.hashCode() : 0);
		#end
        return result;
    }
}
